package javabook.homework01;

import java.math.BigInteger;

public class ch04_3_5 {

	/**
	 * @param args
	 * 
	 * For문을 사용하여 1!, 2!, 3!... 10! 을 구하여라. 
	 * 
	 */
	public static void main(String[] args) {	
		  
		for (int i = 0; i <= 10; i++)
			System.out.format("%3d! = %d%n", i, factorial(i));
		}

		public static BigInteger factorial(int n) {
		    BigInteger fac = BigInteger.ONE;
		    for (int i = 1; i <= n; i++)
		      fac = fac.multiply(BigInteger.valueOf(i));
		    return fac;
		}
	}
